package com.oliet.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jiaZhenpeng
 * @Title: WebConfig
 * @Package com.oliet.config
 * @Description:
 * @date 2024-02-02 13:13
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Value("${request_address}")
    private String REQUEST_ADDRESS;
    @Value("${fileConfig.uploadPath}")
    private String UPLOAD_PATH;

//    http://139.129.234.83:8088/file_source/document/ab43ad66d218430185a4851b5e369d9f.pdf
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file_source/**")  // 定义访问路径
                .addResourceLocations("file:C:/file_source/");  // 定义静态资源存放位置
    }


//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**")
//                .allowedOrigins(REQUEST_ADDRESS) // 允许的前端地址
//                .allowedMethods("GET", "POST", "PUT", "DELETE")
//                .allowedHeaders("*")
//                .allowCredentials(true)
//                .maxAge(3600);
//    }


}
